package com.example.clientsideapplication;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import android.app.IntentService;
import android.content.Intent;

public class DeleteOfferService extends IntentService {

	private ObjectOutputStream outputWriter;
	private Socket socket;
	private String serverAddress;
	private int serverSocket;

	public DeleteOfferService() {
		super("DeleteOfferService");
	}

	@Override
	protected void onHandleIntent(Intent intent) {
		serverAddress = intent.getStringExtra("serverAddress");
		serverSocket = intent.getIntExtra("serverSocket", 21111);

		try {
			socket = new Socket(serverAddress, serverSocket);
			outputWriter = new ObjectOutputStream(socket.getOutputStream());

			int idOffer = intent.getIntExtra("idOffer", -1);
			DataPackage outputMessage = new DataPackage(3, idOffer);
			outputWriter.writeObject(outputMessage);

		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
